#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+5;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+ch-48,ch=getchar();}
	return x*f;
}
int n,r,p[N];
signed main(){
	freopen("permutation.in","r",stdin);
	freopen("permutation.out","w",stdout);
	n=read(),r=read();
	if(n<=8){
		for(int i=1;i<=n;i++) p[i]=i;
		int cnt=0;
		do{
			int sum=p[1],flg=1;
			for(int i=2;i<=n&&flg;i++){
				if(sum<=p[i]) flg=0;
				sum+=p[i];
			}
			cnt+=flg;
			if(cnt==r){
				for(int i=1;i<=n;i++)
					printf("%lld ",p[i]);
				return 0;
			}
		}while(next_permutation(p+1,p+1+n));
	}
	else{
		printf("3 1 2 ");
		for(int i=4;i<n-1;i++) printf("%lld ",i);
		if(r==2) printf("%lld %lld",n,n-1);
		else printf("%lld %lld",n-1,n);
	}
	return 0;
}
